package com.lc.user.express.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lc.user.express.R;
import com.lc.user.express.app.AppContext;
import com.lc.user.express.model.AccountDetailsModel;

import java.util.List;



/**
 * Created by Administrator on 2016/3/14.
 */
public class AccountDetailsAdapter extends BaseListAdapter<AccountDetailsModel.ListBean> {
    public AccountDetailsAdapter(Context context, List<AccountDetailsModel.ListBean> data) {
        super(context, data);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Viewholder viewholder = null;
        AccountDetailsModel.ListBean model = data.get(position);
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_account_details_list, null);
            AppContext.ScaleScreenHelper.loadView((ViewGroup) convertView);
            viewholder = new Viewholder();
            viewholder.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
            viewholder.tv_orderout = (TextView) convertView.findViewById(R.id.tv_orderout);
            viewholder.tv_money = (TextView) convertView.findViewById(R.id.tv_money);
            convertView.setTag(viewholder);
        }
        setContentView(convertView, model,position);

        return convertView;
    }

    private void setContentView(View contentView, AccountDetailsModel.ListBean model, final int position) {
        Viewholder viewholder = (Viewholder) contentView.getTag();
        viewholder.tv_money.setText(model.getAcount()+"元");
        viewholder.tv_orderout.setText(model.getType());
        viewholder.tv_time.setText(model.getPosttime());
    }

    private class Viewholder {
        TextView tv_time;
        TextView tv_orderout;
        TextView tv_money;
    }
}
